#include<iostream>
using namespace std;
class Complex
{
	private:
		double head;
		double tail;
	public:
		friend Complex operator + (double a,Complex b);
		friend Complex operator + (Complex a,double b);
		friend Complex operator + (Complex a,Complex b);
		friend ostream & operator << (ostream &cout,Complex a);
		Complex(double head,double tail)
		{
			this->head=head;
			this->tail=tail;
		}
};
Complex operator + (double a,Complex b)
{
	double reshead=a+b.head;
	Complex res(reshead,b.tail);
	return res;
}
Complex operator + (Complex b,double a)
{
	double reshead=a+b.head;
	Complex res(reshead,b.tail);
	return res;
}
Complex operator + (Complex a,Complex b)
{
	Complex res(a.head+b.head,a.tail+b.tail);
	return res;
}
ostream & operator << (ostream &cout,Complex a)
{
	cout<<a.head<<"+"<<a.tail<<"i";
	return cout;
}
int main()
{
	Complex a(3,9),b(7,4);
	b=a+b;
	a=a+7;
	a=7+a;
	cout<<a<<endl;
	cout<<b<<endl;
	return 0;
}
